﻿using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.Reports.ZPSPXT.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.Reports.ZPSPXT
{
    //[Authorize]
    [ApiController]
    [Route("api/Reports/ZPSPXT")]
    public class ZPSPXTController
    {
        private readonly IZPSPXTService _service;
        public ZPSPXTController(IZPSPXTService service)
        {
            _service = service;
        }

        /// <summary>
        /// 报表查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("GetAll")]
        public async Task<PagedResultDto<ZPSPXTDto>> GetAll([FromBody] ZPSPXTInput input)
        {
            return await _service.GetAllAsync(input);
        }

        /// <summary>
        /// 报表导出
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExportExcel")]
        public async Task<XlsxFileResult<ZPSPXTDto>> ExportExcel([FromBody] ZPSPXTInput input)
        {
            var rst = await _service.ExportAsync(input);
            return new XlsxFileResult<ZPSPXTDto>(rst, "导出Excel");
        }

        [HttpPost]
        [Route("FixData")]
        public async Task FixData()
        {
            await _service.FixData();
        }
    }
}
